package com.lyj.controller;

import com.lyj.pojo.Result;
import com.lyj.service.PersonalService;
import com.lyj.pojo.vo.FamilyMemberVO;
import com.lyj.pojo.vo.UserInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping("/personal")
public class PersonalController {

    @Autowired
    private PersonalService personalService;

    /**
     * 获取个人信息（供前端展示）
     */
    @GetMapping("/info")
    public Result getUserInfo(@RequestParam Integer userId) {
        UserInfoVO userInfoVO = personalService.getUserInfoForView(userId);
        return Result.success(userInfoVO);
    }

    /**
     * 获取家庭成员列表（仅管理员，供前端展示）
     */
    @GetMapping("/family-members")
    public Result getFamilyMembers(@RequestParam Integer userId) {
        List<FamilyMemberVO> members = personalService.getFamilyMembersForView(userId);
        return Result.success( members);
    }
}